package com.me.pikachu.main;

import com.badlogic.gdx.Gdx;

public class MatrixProcess {

	private int[][] originalMatrix;

	private int[][] newMatrix;

	public MatrixProcess() {
		newMatrix = createMatrix();
	}

	private int[][] createMatrix() {

		int originalMatrix[][] = { { 4, -10, 4, 2 }, { 2, -10, 4, 2 },
				{ 2, -10, -10, -10 }, { 2, -10, -10, 4 }, { 2, 3, 4, 5 } };
		this.originalMatrix = originalMatrix;

		int lengthRow = originalMatrix.length;
		int lengthColumn = originalMatrix[0].length;

		int[][] newMatrix = new int[lengthRow + 2][lengthColumn + 2];

		for (int i = 0; i < lengthRow + 2; i++) {
			for (int j = 0; j < lengthColumn + 2; j++) {
				if (i == 0 || j == 0 || i == lengthRow + 1
						|| j == lengthColumn + 1)
					newMatrix[i][j] = Point.COMPARE;
				else
					newMatrix[i][j] = originalMatrix[i - 1][j - 1];
			}
		}

		// Point src = new Point(0, 0, a);
		// Point dest = new Point(1, 2);
		// Stack<Point> path = src.getPath(dest);
		//
		// while (!path.isEmpty()) {
		// Point p = path.pop();
		// Gdx.app.log("TAG PATH", "message: " + p.getI() + ", " + p.getJ());
		// }

		return newMatrix;
	}

	public void setMatrix(Point source, Point dest) {
		test();
		newMatrix[source.i][source.j] = Point.COMPARE;
		newMatrix[dest.i][dest.j] = Point.COMPARE;

		originalMatrix[source.i - 1][source.j - 1] = Point.COMPARE;
		originalMatrix[dest.i - 1][dest.j - 1] = Point.COMPARE;

	}

	public int[][] getOrigialMatrix() {
		return originalMatrix;
	}

	public int[][] getNewMatrix() {
		return newMatrix;
	}

	private void test() {
		for (int i = 0; i < newMatrix.length; i++) {
			for (int j = 0; j < newMatrix[0].length; j++) {
				System.out.print(newMatrix[i][j] + " ");
			}
			System.out.println();
		}

		Gdx.app.log("matrix process", "------------------");
	}
}
